package top.kaoshanji.p1ch02d;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;

/**
 * 代码清单 p1ch02d-03：MethodHandles#constant的使用示例
 * author kaoshanji
 * ^_^
 * create time 2025/1/3 16:54
 */
public class MethodHandlesExample03 {

    private static final Logger logger = LogManager.getLogger(MethodHandlesExample03.class);

    public static void main(String[] args) throws Throwable {
        logger.info("...代码清单 p1ch02d-03：MethodHandles#constant的使用示例...");

        MethodHandle mh = MethodHandles.constant(String.class, "Hello");
        String value = (String)mh.invoke();

        System.out.println(value);

    }

}
